package com.nth.rooster.core.entities;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonManagedReference;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;


@Entity
@Table(name="RAM_USERS")
public class RamUsers implements Serializable{

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "USER_ID")
	private Long userId;

	@Column(name = "USER_FIRST_NAME")
	private String userFirstName;

	@Column(name = "USER_LAST_NAME")
	private String userLastName;

	@Column(name = "IS_ACTIVE")
	private Boolean active;

	@Column(name = "IS_INTERNAL")
	private Boolean isInternal;
	
	@Column(name = "EMAIL")
	private String email;
	
	@Column(name = "PHONE_NUMBER")
	private String phoneNumber;
	
	@Column(name = "DATE_OF_BIRTH")
	private Date dateOfBirth;
	
	@Column(name = "DATE_OF_JOINING")
	private Date dateOfJoining;
	
	@Column(name = "COLLEGE_UNIQUE_ID")
	private String collegeUniqueID;

	@Column(name = "CREATED_DATE", columnDefinition = "DATE")
	private Timestamp createdDate;
	
	@Column(name = "CREATED_BY")
	private Long createdBy;
	
	@Column(name = "MODIFIED_DATE", columnDefinition = "DATE")
	private Timestamp modifiedDate;

	@Column(name = "MODIFIED_BY")
	private Long modifiedBy;
	
	@ManyToMany(fetch = FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.PERSIST})
	@JoinTable(name = "RAM_USER_ROLES", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID", nullable = false, updatable = false) })
	@JsonManagedReference
	@Fetch(FetchMode.JOIN)
	private Set<RamRoles> ramRoles = new HashSet<RamRoles>();
	
	@ManyToMany(fetch = FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.PERSIST})
	@JoinTable(name = "RAM_USER_CIRCLE_OWNER", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "CIRCLE_ID", nullable = false, updatable = false) })
	@JsonManagedReference
	@Fetch(FetchMode.JOIN)
	private Set<RamCircles> ownerOfCircles = new HashSet<RamCircles>(); 
	
	@OneToMany(fetch=FetchType.LAZY,mappedBy= "userID")
	@Cascade({org.hibernate.annotations.CascadeType.ALL})
	private Set<RamUserCircleMember> memberForcircles = new HashSet<RamUserCircleMember>();

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUserFirstName() {
		return userFirstName;
	}

	public void setUserFirstName(String userFirstName) {
		this.userFirstName = userFirstName;
	}

	public String getUserLastName() {
		return userLastName;
	}

	public void setUserLastName(String userLastName) {
		this.userLastName = userLastName;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public Boolean getIsInternal() {
		return isInternal;
	}

	public void setIsInternal(Boolean isInternal) {
		this.isInternal = isInternal;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public Date getDateOfJoining() {
		return dateOfJoining;
	}

	public void setDateOfJoining(Date dateOfJoining) {
		this.dateOfJoining = dateOfJoining;
	}

	public String getCollegeUniqueID() {
		return collegeUniqueID;
	}

	public void setCollegeUniqueID(String collegeUniqueID) {
		this.collegeUniqueID = collegeUniqueID;
	}

	public Timestamp getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Timestamp createdDate) {
		this.createdDate = createdDate;
	}

	public Long getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(Long createdBy) {
		this.createdBy = createdBy;
	}

	public Timestamp getModifiedDate() {
		return modifiedDate;
	}

	public void setModifiedDate(Timestamp modifiedDate) {
		this.modifiedDate = modifiedDate;
	}

	public Long getModifiedBy() {
		return modifiedBy;
	}

	public void setModifiedBy(Long modifiedBy) {
		this.modifiedBy = modifiedBy;
	}

	public Set<RamRoles> getRamRoles() {
		return ramRoles;
	}

	public void setRamRoles(Set<RamRoles> ramRoles) {
		this.ramRoles = ramRoles;
	}

	public Set<RamCircles> getOwnerOfCircles() {
		return ownerOfCircles;
	}

	public void setOwnerOfCircles(Set<RamCircles> ownerOfCircles) {
		this.ownerOfCircles = ownerOfCircles;
	}

	public Set<RamUserCircleMember> getMemberForcircles() {
		return memberForcircles;
	}

	public void setMemberForcircles(Set<RamUserCircleMember> memberForcircles) {
		this.memberForcircles = memberForcircles;
	}
	
	

}

